let auditResult;
$(function (){
    syntory();
    function syntory(){

        let checkId = sessionStorage.getItem('matronId');

            AjaxGet( '/userAunt/getUserAuntById' , {id:checkId} ).then(function (response){
                let userInfo = response.data.userDO;  //用户
                let matron = response.data.jazUserAuntDO;  // 月嫂

                $("#username").html(userInfo.name || '' ); //用户名字
                $("#mobile").html(userInfo.orderPhone || ''); //用户电话
                $("#nativePlace").html( userInfo.nativePlace || '' ); // 籍贯
                $("#age").html( userInfo.age +'岁'  || ''); // 年龄
                $("#sex").html( userInfo.sex == '1' ? '男':'女' ); // 性别
                $("#zodiac").html( userInfo.zodiac || '' ); // 生肖
                $("#constellation").html( userInfo.constellation || '' ); // 星座
                $("#maritalStatus").html( userInfo.maritalStatus  || ''); // 婚姻
                $("#education").html( userInfo.education || '' ); // 学历
                $("#height").html( userInfo.height +'cm' || '' ); // 身高
                $("#weight").html( userInfo.weight +'kg' || '' ); // 体重
                // $("#detailedAddress").html( userInfo.detailedAddress  || ''); // 现住址
                $("#detailedAddress").html(userInfo?.province == userInfo?.city ? `${userInfo?.city}${userInfo?.district}${userInfo?.detailedAddress}` :
                    `${userInfo?.province}${userInfo?.city}${userInfo?.district}${userInfo?.detailedAddress}`); // 现住址
                $("#gmtCreate").html( matron.signingStatus == 0  ? '待签约':'已签约' ); // 签约状态
                $("#time").html( matron.createTime  || '' ); // 时间
                $("#introduction").html( matron.introduction  || ''); // 自我介绍
                $("#residentHome").html( matron.residentHome == '0' ? '是':'否' ); // 是否住家
                $("#desireSalary").html( '￥'+ matron.desireSalary+'/月' || '' ); // 期望工资
                $("#workExperience").html( matron.workExperience +'年'  || ''); // 工作经验
                // $("#skill").html( matron.skill  || ''); // 个人技能

                $("#serveTotal").html(matron.serveTotal);
                $("#examinationCondition").html(matron.examinationCondition.replace(',','、'));
                $("#nurseContent").html(matron.nurseContent.replace(',','、'));
                $("#skill").html(matron.skill.replace(',','、'));


                if( matron.experience ){
                    let experience = JSON.parse(matron.experience),srr = '';
                    // $("#experience").html( matron.experience || '' ); // 工作经历
                    experience?.map(function (v){
                        srr += `
                         <div class="layui-form-item">
                            ${v.startTime}~${v.endTime}
                        </div>
                        <div class="layui-form-item">
                            ${v.describe}
                        </div>`;
                    })
                    $("#experience").html(srr);
                }

                $("#order").html( matron.orderCount || '' ); // 订单数

                $("#recharge").html(response.data.jazSysProject || '')

                //个人标签
                let str = '';
                response.data.jazSysLabelDO?.forEach(function (v){
                    str += `<span class="layui-badge layui-bg-green" style="margin-right: 10px">${v.describe || ''}</span>`
                })
                $("#tips").html(str);

                //寸照
                $("#inchPhoto").html(`<div class="layui-inline"><img class="upImg" width="100" src="${matron.inchPhoto || ''}"></div>`);
                //身份证正面
                $("#idPhotoFront").html(`<div class="layui-inline"><img class="upImg" width="100" src="${matron.idPhotoFront || ''}"></div>`);
                //身份证反面
                $("#idPhotoSide").html(`<div class="layui-inline"><img class="upImg" width="100" src="${matron.idPhotoSide || ''}"></div>`);
                //工作/生活照
                str = '';
                let lifePhoto = matron.lifePhoto?.split(',')
                lifePhoto?.forEach(function (v){
                    str += `<div class="layui-inline">
                                <img class="upImg" width="100" src="${v}">
                            </div>
                           `;
                });
                $("#lifePhoto").html(str);
                //技能证书
                str = '';
                let certificate = matron.certificate.split(',')
                certificate?.forEach(function (v){
                    str += `<div class="layui-inline">
                            <img class="upImg" width="100" src="${v}">
                        </div>
                       `;
                });
                $("#certificate").html(str);
                //体检报告
                str = '';
                let report = matron.report.split(',')
                report?.forEach(function (v){
                    str += `<div class="layui-inline">
                                <img class="upImg" width="100" src="${v}">
                            </div>
                           `;
                });
                $("#report").html(str);
                //展示状态
                $('input[name="showStatus"]')?.each(function (k,v){
                    if( $(v).val() == matron.showStatus ){
                        $(v).attr('checked',true)
                    }
                })
            }).catch(function (error) {
                layer.msg(error.msg)
            })
    }

    $('body').on('click','.upImg',function (){
        let str = `<div class="popup"></div><div class='magnify'><img src='${$(this).attr('src')}'></div>`;
        $('body').append(str)
    })

    $('body').on('click','.popup',function (){
        $(this).remove();
        $(".magnify").remove();
    })

})

$("#but").click(function (){
    let matronId = sessionStorage.getItem('matronId');
    let show = $('input[type="radio"]:checked').val();

    AjaxPost('/userAunt/examineAunt',{
        id: matronId,
        showStatus: show,
        auditResult: 0,
        auditStatus: 1
    }).then(function (response){
        parent.layer.msg("操作成功");
        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
        parent.layer.close(index);
        parent.load();
    }).catch(error => {
        layer.msg(error.msg)
    })

})